/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.dao;

import br.com.deployment.daogenerico.DaoGenerico;
import br.com.deployment.entidade.fermojupi.Emolumento;
import br.com.deployment.entidade.fermojupi.EmolumentoItem;
import br.com.deployment.interfaces.EmolumentoItemDaoIn;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author luciano
 */
@Stateless
@LocalBean
public class EmolumentoItemDao extends DaoGenerico<EmolumentoItem> implements EmolumentoItemDaoIn{

    public EmolumentoItemDao() {
        super(EmolumentoItem.class);
    }
    
      public List<EmolumentoItem> findPesquisar(EmolumentoItem emolItem) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public List<EmolumentoItem> findEmolumentoItem(Emolumento emolItem) {
        List<EmolumentoItem> list = new ArrayList<EmolumentoItem>();
        if(emolItem != null){
             String sql = "Select e from EmolumentoItem e where e.status = true and e.emol.id = "+ emolItem.getId();
             
             Query query = getEm().createQuery(sql);
              list = query.getResultList();
              System.out.println(sql);
        }
        
        return list;
    
    }
    
    public List<EmolumentoItem> findCodItemEmolumento(String str){
        List<EmolumentoItem> lstEmol = new ArrayList<EmolumentoItem>();
        String sql = "Select e from EmolumentoItem e JOIN e.atoItem a where"
                + " a.codigo like :cod";
        Query query = getEm().createQuery(sql); 
        if(str != null){
            query.setParameter("cod", str);
        }
        lstEmol = query.getResultList();
        return lstEmol;
    }
    
}
